//
//  ADProtocol.h
//  ADKit
//
//  Created by duzexu on 2017/12/1.
//  Copyright © 2017年 duzexu. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AFNetworkReachabilityManager.h"

/// Block
///------
typedef void (^AD_VoidBlock)(void);
typedef BOOL (^AD_BoolBlock)(void);
typedef int  (^AD_IntBlock) (void);
typedef id   (^AD_IDBlock)  (void);

typedef void (^AD_VoidBlock_Int)(int);
typedef BOOL (^AD_BoolBlock_Int)(int);
typedef int  (^AD_IntBlock_Int) (int);
typedef id   (^AD_IDBlock_Int)  (int);

typedef void (^AD_VoidBlock_String)(NSString *);
typedef BOOL (^AD_BoolBlock_String)(NSString *);
typedef int  (^AD_IntBlock_String) (NSString *);
typedef id   (^AD_IDBlock_String)  (NSString *);

typedef void (^AD_VoidBlock_id)(id);
typedef BOOL (^AD_BoolBlock_id)(id);
typedef int  (^AD_IntBlock_id) (id);
typedef id   (^AD_IDBlock_id)  (id);

typedef void (^AD_VoidBlock_bool)(BOOL);
typedef BOOL (^AD_BoolBlock_bool)(BOOL);
typedef int  (^AD_IntBlock_bool) (BOOL);
typedef id   (^AD_IDBlock_bool)  (BOOL);

@class ADViewModel,AFNetworkReachabilityManager;

@protocol ADConfigurationDelegate<NSObject>

@optional
/// 系统初始化
- (void)ad_systemConfiguration;

/// 第三方信息初始化
- (void)ad_thirdConfiguration;

/// 数据库信息初始化
- (void)ad_dataBaseConfiguration;

/// 其他信息初始化
- (void)ad_otherConfiguration;

/// 推送信息回调
- (void)ad_handleRemoteNotification:(NSDictionary *)remoteInfo;

/// 连续三次崩溃保护
- (void)ad_crashProtect;

@end

/// A protocol which is adopted by views which are backed by view models.
@protocol ADReactiveView <NSObject>

/// Binds the given view model to the view.
///
/// viewModel - The view model
- (void)bindViewModel:(id)viewModel;

@end

@protocol ADViewModelServices <NSObject>

@property (nonatomic, readonly, strong) AFNetworkReachabilityManager *reachabilityManager;

/// Pushes the corresponding view controller.
///
/// Uses a horizontal slide transition.
/// Has no effect if the corresponding view controller is already in the stack.
///
/// viewModel - the view model
/// animated  - use animation or not
- (void)pushViewModel:(ADViewModel *)viewModel animated:(BOOL)animated;

- (void)pushContextViewModel:(ADViewModel *)viewModel animated:(BOOL)animated;

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated;

- (void)pushContextViewController:(UIViewController *)viewController animated:(BOOL)animated;

/// Pops the top view controller in the stack.
///
/// animated - use animation or not
- (void)popViewModelAnimated:(BOOL)animated;

- (void)popContextViewModelAnimated:(BOOL)animated;

/// Pops until there's only a single view controller left on the stack.
///
/// animated - use animation or not
- (void)popToRootViewModelAnimated:(BOOL)animated;

/// Present the corresponding view controller.
///
/// viewModel  - the view model
/// animated   - use animation or not
/// completion - the completion handler
- (void)presentViewModel:(ADViewModel *)viewModel animated:(BOOL)animated completion:(AD_VoidBlock)completion;

- (void)presentViewController:(UIViewController *)viewController animated:(BOOL)animated completion:(AD_VoidBlock)completion;

- (void)rootPresentViewController:(UIViewController *)viewController animated:(BOOL)animated completion:(AD_VoidBlock)completion;

- (void)rootPresentViewModel:(ADViewModel *)viewModel animated:(BOOL)animated completion:(AD_VoidBlock)completion;

- (void)presentContextViewModel:(ADViewModel *)viewModel animated:(BOOL)animated completion:(AD_VoidBlock)completion;

- (void)presentContextViewController:(UIViewController *)viewController animated:(BOOL)animated completion:(AD_VoidBlock)completion;

/// Dismiss the presented view controller.
///
/// animated   - use animation or not
/// completion - the completion handler
- (void)dismissViewModelAnimated:(BOOL)animated completion:(AD_VoidBlock)completion;

- (void)dismissContextViewModelAnimated:(BOOL)animated completion:(AD_VoidBlock)completion;

/// Reset the corresponding view controller as the root view controller of the application's window.
///
/// viewModel - the view model
- (void)resetRootViewModel:(ADViewModel *)viewModel;

- (void)resetRootViewController:(UIViewController *)viewController;

@end

@protocol ADNavigator <NSObject>

@optional

/// The controller storyboard
@property (nonatomic, strong) UIStoryboard *storyboard;

/// The self controller class
@property (nonatomic, assign) Class viewControllerClass;

@end

@protocol ADSystemLifeCycle <NSObject>

- (void)applicationWillResignActive:(UIApplication *)application;

- (void)applicationDidEnterBackground:(UIApplication *)application;

- (void)applicationWillEnterForeground:(UIApplication *)application;

- (void)applicationDidBecomeActive:(UIApplication *)application;

- (void)applicationWillTerminate:(UIApplication *)application;

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application;

@end

@protocol ADControllerLifeCycle <NSObject>

- (void)viewDidLoad;

- (void)viewWillAppear:(BOOL)animated;

- (void)viewDidAppear:(BOOL)animated;

- (void)viewWillDisappear:(BOOL)animated;

- (void)viewDidDisappear:(BOOL)animated;

- (void)reachabilityStatusDidChange:(AFNetworkReachabilityStatus)status;

@end
